package com.gimi.cloud.bbp.manage.controller.page;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.utils.reqhead.Response;
import com.gimi.cloud.bbp.dto.page.PageConfigDTO;
import com.gimi.cloud.bbp.dto.page.PageTemplateDTO;
import com.gimi.cloud.bbp.manage.service.page.PageConfigService;

/**
 * 页面Controller
 * @author zhoufuhang
 *
 */
@RestController
public class PageConfigController {
	
	@Autowired private PageConfigService pageConfigService;
	
	/**
	 * 获取页面列表
	 * @param dto
	 * @param response
	 */
	@RequestMapping("/pc/getPageConfigList")
	public Response getList(@RequestBody PageConfigDTO dto, HttpServletResponse response) {
		Response resp = new Response();
        resp.setRes_data(pageConfigService.getPageConfigList(dto));
        resp.setResponseCode(ResponseCodeEnum.SUCCESSED, response);
		return resp;
	}
	
	/**
	 * 删除页面
	 * @param dto
	 * @param response
	 */
	@RequestMapping("/pc/delPageConfig")
	public Response delInfo(@RequestBody PageConfigDTO dto, HttpServletResponse response) {
		pageConfigService.delPageConfig(dto.getIds());
		Response resp = new Response();
		resp.setResponseCode(ResponseCodeEnum.SUCCESSED, response);
		return resp;
	}
	
	/**
	 * 保存页面
	 * @param dto
	 * @param response
	 */
	@RequestMapping("/pc/savePageConfig")
	public Response saveInfo(@RequestBody PageConfigDTO dto, HttpServletResponse response) {
		pageConfigService.savePageConfig(dto);
		Response resp = new Response();
		resp.setResponseCode(ResponseCodeEnum.SUCCESSED, response);
		return resp;
	}
	
	/**
	 * 获取页面
	 * @param dto
	 * @param response
	 */
	@RequestMapping("/pc/getPageConfig")
	public Response getInfo(@RequestBody PageTemplateDTO dto, HttpServletResponse response) {
		Response resp = new Response();
		resp.setResponseCode(ResponseCodeEnum.SUCCESSED, response);
		resp.setRes_data(pageConfigService.getInfoById(dto.getId()));
		return resp;
	}

}
